package zl.io;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class CopyDemo
{
	public static void main(String[] args)
	{
		File outFile = new File("C:" + File.separator + "Test.txt");
		File inFile = new File("D:" + File.separator + "Test.txt");
		OutputStream out = null;
		InputStream in = null;
		try
		{
			out = new FileOutputStream(inFile);
			in = new FileInputStream(outFile);
			int temp = 0;
			while((temp = in.read()) != -1)
			{
				out.write(temp);
			}
		}
		catch (FileNotFoundException e)
		{
			e.printStackTrace();
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
		finally
		{
			try
			{
				if(out != null)
				{
					out.close();
				}
				if(in != null)
				{
					in.close();
				}
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
		}
	}
}